class Solution(object):
    def twoSumLessThanK(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: int
        """
        nums.sort()
        left_index = 0
        right_index = len(nums) - 1
        value = -1
        while left_index < right_index:
            if nums[left_index] + nums[right_index] < k:
                value = max(value, nums[left_index] + nums[right_index])
                left_index += 1
            else:
                right_index -= 1
        return value


data = Solution()
nums = [10,20,30]
k = 15
print(data.twoSumLessThanK(nums, k))